package com.liang.maogouyuyin.ui.fragment;

import android.annotation.SuppressLint;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;

import com.liang.maogouyuyin.R;
import com.liang.maogouyuyin.databinding.FragmentPetMenuBinding;
import com.liang.maogouyuyin.ui.adapter.PetMenuFragmentAdapter;
import com.google.android.material.tabs.TabLayoutMediator;

public class PetMenuFragment extends Fragment {
    FragmentPetMenuBinding binding;
    @SuppressLint("StaticFieldLeak")
    public static FrameLayout mFeedContainer;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = FragmentPetMenuBinding.inflate(inflater, container, false);
        return binding.getRoot();
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState){
        super.onViewCreated(view, savedInstanceState);

        initView();
    }

    private void initView() {
        binding.petMenuViewPager.setAdapter(new PetMenuFragmentAdapter(requireActivity()));

        new TabLayoutMediator(binding.petMenuTabLayout, binding.petMenuViewPager, (tab, position) -> {
            switch (position) {
                case 0:
                    tab.setText(getString(R.string.pet_menu_variety));
                    break;
                case 1:
                    tab.setText(getString(R.string.pet_menu_training));
                    break;
                case 2:
                    tab.setText(getString(R.string.pet_menu_animal));
            }
        }).attach();
    }
}